]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Extend ScreenshotArea parameter validation
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 4 Nov 2013 10:14:44 +0000 (11:14 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 4 Nov 2013 15:21:45 +0000 (16:21 +0100)
We currently only ensure that width and height are positive, so it
is still possible to pass in values that don't make any sense at all
(which may even result in a crash when exceeding limits imposed by
X11).
There is nothing to screenshot outside the actual screen area, so
restrict the parameters to that.

https://bugzilla.gnome.org/show_bug.cgi?id=699752

js/ui/screenshot.js

index 10435c5b8a8a44bf2c0b30d168344bacb45c8b00..73ca773a910ef311dc5a14f28ef4318679595735 100644 (file)
@@ -79,7 +79,9 @@ const ScreenshotService = new Lang.Class({
 
     ScreenshotAreaAsync : function (params, invocation) {
         let [x, y, width, height, flash, filename, callback] = params;
-        if (height <= 0 || width <= 0) {
+        if (x < 0 || y < 0 ||
+            width <= 0 || height <= 0 ||
+            x + width > global.screen_width || y + height > global.screen_height) {
             invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
                         "Invalid params");
             return;